/**
 *
 */
package com.example.mdteachingsys.action;

import com.opensymphony.xwork2.ActionSupport;
import com.xscj.domain.Message;
import com.xscj.service.MessageService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.HashMap;
import java.util.Map;

/**
 * @author leorain
 */
public class MessageReplyAction extends ActionSupport {

    /**
     *
     */
    private static final long serialVersionUID = -7652431825461314873L;

    @Autowired
    @Qualifier("messageServiceImpl")
    private MessageService messageService;

    private Long id;
    private String replyContent;
    private String result;


    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    @Override
    public String execute() throws Exception {
        Message message = new Message();
        message.setId(id);
        message.setReplyContent(replyContent);
        messageService.updateMessage(message);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("flag", true);
        JSONObject json = JSONObject.fromObject(map);
        result = json.toString();
        return SUCCESS;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getReplyContent() {
        return replyContent;
    }

    public void setReplyContent(String replyContent) {
        this.replyContent = replyContent;
    }
}
